<template>
  <view class="titleClass">
    <span @click="delFunc">验伪系统</span>
    <!-- @click="delFunc" -->
  </view>
</template>

<script setup lang="ts">
import { getDeleteShuiAllDataAPI, getDeleteMTAllDataAPI } from '@/services/allData'
import { useWebsocketStore } from '@/stores/modules/websocket'

const clickCount = ref(0)
const timer = ref()
const delFunc = async () => {
  if (timer.value) {
    clearTimeout(timer.value)
  }
  clickCount.value++
  console.log(clickCount.value)
  timer.value = setTimeout(() => {
    clickCount.value = 0
  }, 500)
  // if (clickCount.value % 3 == 0) {
  //   window.$message.create('模拟数据清空', {
  //     duration: 2000,
  //   })
  // }
  if (clickCount.value >= 3) {
    await getDeleteMTAllDataAPI() //茅台
    // await getDeleteShuiAllDataAPI() //水
    let date = Date.now()
    useWebsocketStore().date = date
  }
}
</script>

<style lang="scss" scoped>
.titleClass {
  width: 100vw;
  height: 10vh;
  display: flex;
  justify-content: center;
  align-items: center;
  span {
    width: 99.848958vw;
    height: 8.794444vh;
    background: url('../../static/images/headline.png') no-repeat;
    background-size: 100% 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #0ff;
    font-size: 3.425926vh;
  }
}
</style>
